

public class Server {

	public static void main(String[] args) throws Exception {
		ServerSocket welcomeSocket = new ServerSocket(1234);
		ConnectionSocket connection1, connection2, connection3;
		String data;
		while(true)
		{
			connection1 = welcomeSocket.accept();
			connection2 = welcomeSocket.accept();
			connection3 = welcomeSocket.accept();
			if(connection3 == null)
				System.out.println("Connection3 could not be established.");
			data = new String(connection1.receive());
			data = data.toUpperCase();
			connection1.send(data.getBytes());
			data = new String(connection2.receive());
			data = data.toUpperCase();
			connection2.send(data.getBytes());
			connection1.close();
			connection3 = welcomeSocket.accept();
			data = new String(connection3.receive());
			data = data.toUpperCase();
			connection3.send(data.getBytes());
			connection3.close();
			connection2.close();
		}
	}
}

